<?php
header("Content-Type: application/json; charset=utf-8;");
$connect = mysqli_connect('localhost', 'root', 'root', '24mysql');
if(!$connect){
    echo json_encode([
        'code' => 0,
        'msg' => '数据库连接失败',
        'data' => null
    ]);
}
$sql = "select name,date,salary from staff t join salary s on t.id=s.salary_id where t.id=1";
$query = mysqli_query($connect, $sql);
$result = mysqli_fetch_all($query,MYSQLI_ASSOC);
$xAxis = [];
$yAxis = [];
foreach ($result as $val){
    array_push($xAxis,$val['date']);
    array_push($yAxis,$val['salary']);

}
echo json_encode([
    'code' => 1,
    'msg' => '数据库连接成功',
    'data' =>[
        'xAxis' => $xAxis,
        'yAxis' => $yAxis,
    ]
]);


